﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default2 : System.Web.UI.Page
{
    UserDAO uDao = new UserDAO();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void txtFirstName_TextChanged(object sender, EventArgs e)
    {

    }
    protected void btnCreateUser_Click(object sender, EventArgs e)
    {
        pnlMessage.Visible = true;
        if (this.IsValid)
        {
            User u = new User()
            {
                UserName = txtUserName.Text.Trim(),
                UserPassword = txtPassword.Text.Trim(),
                Address = txtAddress.Text.Trim(),
                FirstName = txtFirstName.Text.Trim(),
                LastName = txtLastName.Text.Trim(),
                Phone = txtPhone.Text.Trim(),
                Genre = drpGenre.SelectedItem.Text,
                Email = txtEmail.Text.Trim()
            };
            int result = uDao.Create(u);
            if (result > 0) {
                lblMessage.Text = "Success!";
            }
        }
        else
        {

            lblMessage.Text = "Some field is non-validated!";
        }
    }
}